package com.mjy.pages;

import static org.testng.Assert.assertEquals;

import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import base.BaseDriver;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import com.mjy.pages.ChatPage;

public class PageTest extends BaseDriver {
	ChatPage chatPage;

	@BeforeClass
	public void init() throws InterruptedException {
		chatPage = new ChatPage(driver);
		chatPage.login();
		Thread.sleep(3000);
		chatPage.withAdmin();
		Thread.sleep(2000);
	}

	// 发送消息
	@Test(priority = 1)
	public void sendTest() throws InterruptedException {
		chatPage.send("mjy");
		Thread.sleep(3000);
	}

	// 发送只有空格的消息
	@Test(priority = 2)
	public void sendBlankTest() throws InterruptedException {
		chatPage.sendBlank();
		Thread.sleep(3000);
	}

	// 发送包含空格的消息
	@Test(priority = 3)
	public void sendMessageWithBlankTest() throws InterruptedException {
		chatPage.sendMessageWithBlank();
		Thread.sleep(3000);
	}

	// 发送拍摄的图片
	@Test(priority = 4)
	public void sendTakingPicturesTest() throws InterruptedException {
		chatPage.sendTakingPictures();
		Thread.sleep(3000);
	}

	// 发送本地图片
	@Test(priority = 5)
	public void sendPictures() throws InterruptedException {
		chatPage.sendpictures();
		Thread.sleep(5000);
	}

	// 查看发送的图片
	@Test(priority = 6)
	public void sendImageTest() throws InterruptedException {
		chatPage.seeImage();
		Thread.sleep(3000);
	}

	// 发送文件
	@Test(priority = 7)
	public void sendFileTest() throws InterruptedException {
		chatPage.sendFile();
		Thread.sleep(3000);
	}

	// 取消操作
	@Test(priority = 8)
	public void cancelTest() throws InterruptedException {
		chatPage.cancel("mjy");
		Thread.sleep(3000);
	}

	// 发送复制的消息
	@Test(priority = 9)
	public void sendCopyTextTest() throws InterruptedException {
		chatPage.sendCopy("copymjy");
		Thread.sleep(3000);

	}

	// 转发消息
	@Test(priority = 10)
	public void relayTest() throws InterruptedException {
		chatPage.relay("mjy", "test");
		boolean b = true;
		try {
			chatPage.relayedText();
		} catch (Exception e) {
			b = false;
		}
		System.out.println("转发消息：b=" + b);
		Thread.sleep(3000);
		assertEquals(b, true);
	}

	// 分享消息
	@Test(priority = 11)
	public void shareTest() throws InterruptedException {
		chatPage.share("mjy", "test");
		Thread.sleep(3000);
		chatPage.goback();
		Thread.sleep(3000);
	}

	// 撤回消息成功
	@Test(priority = 12)
	public void recallSuccessTest() throws InterruptedException {
		boolean b = chatPage.recall("mjy");
		System.out.println("撤回消息成功：b=" + b);
		Thread.sleep(3000);
		assertEquals(b, true);
	}

	// 撤回消息失败
	@Test(priority = 13)
	public void recallFailTest() throws InterruptedException {
		boolean b = chatPage.recall("mjy");
		System.out.println("撤回消息失败：b=" + b);
		Thread.sleep(3000);
		assertEquals(b, false);
	}

	// 向下滚动查看消息
	@Test(priority = 14)
	public void swipToSeeMessage() throws InterruptedException {
		chatPage.swipToSeeMessage();
		Thread.sleep(3000);
	}

	// 收藏操作
	@Test(priority = 15)
	public void collectUserTest() throws InterruptedException {
		chatPage.collectUser();
		Thread.sleep(3000);
	}

	// 取消收藏操作
	@Test(priority = 16)
	public void cancelCollectUserTest() throws InterruptedException {
		chatPage.cancelCollectUser();
		Thread.sleep(3000);
	}

	// 查看资料
	@Test(priority = 17)
	public void seeDataTest() throws InterruptedException {
		chatPage.seeData();
		Thread.sleep(3000);
	}

	// 查看对方资料
	@Test(priority = 18)
	public void seeDataByYourAvatarTest() throws InterruptedException {
		chatPage.seeDataByYourAvatar();
		Thread.sleep(3000);
		chatPage.goback();
		Thread.sleep(3000);
	}

	// 查看我的资料
	@Test(priority = 19)
	public void seeDataByMyAvatarTest() throws InterruptedException {
		chatPage.seeDataByMyAvatar();
		Thread.sleep(3000);
		chatPage.goback();
		Thread.sleep(3000);
	}

	// 返回
	@Test(priority = 20)
	public void gobackTest() throws InterruptedException {
		chatPage.goback();
		Thread.sleep(3000);
	}

}
